*-------------------------------------------------------------------------------
* Price and Wasserman (2024), "The Summer Drop in Female Employment"
*
* Description: Re-normalize estimates and save them to disk.
*-------------------------------------------------------------------------------

capture program drop process_estimates
program define process_estimates
	* User supplies a relative path and a name for the model
	syntax, path(string) model(string) [raw mayjuly]

	if "`raw'" == "" {
		* Take the May estimate if present; otherwise presume it's zero
		capture display _b[5.month]
		if _rc == 0 {
			local may = _b[5.month]
		}
		else {
			local may = 0
		}

		* Transform coefficients so that May effect is first
		forvalues m = 0/12 {
			local mm = mod(`m' + 5, 12) + 12 * (mod(`m' + 5, 12) == 0)

			if `mm' == 5 {
				local coeflist "`coeflist' (coef`m' = `may')"
			}
			else {
				local coeflist "`coeflist' (coef`m' = _b[`mm'.month])"
			}
		}

		* If requested: calculate the estimated change from May to July
		if "`mayjuly'" != "" {
			local coeflist "`coeflist' (mayjuly = _b[7.month] - `may')"
		}

		* Convert estimates
		quietly xlincom `coeflist', post
	}

	* Save the estimates to disk
	estimates save "$basepath/models/`path'/`model'.ster", replace
end
